<?php
/**
 * tpAdmin [a web admin based ThinkPHP5]
 *
 * @author yuan1994 <tianpian0805@gmail.com>
 * @link http://tpadmin.yuan1994.com/
 * @copyright 2016 yuan1994 all rights reserved.
 * @license http://www.apache.org/licenses/LICENSE-2.0
 */

//------------------------
// 管理后台首页
//-------------------------

namespace app\admin\controller;

use app\admin\Controller;
use think\Db;

class Configs extends Controller
{
    public function index()
    {
        if($this->request->isPost()){
            $texts = input('post.');
            $result = Db::name('config')->where(['type'=>12])->update(['texts' =>$texts['editorValue'] ]);
            if (!$result) {
                return ajax_return_error('失败');
            }
            return ajax_return_adv('成功');
        }else{
            $list = Db::name('config')->where(['type'=>12])->find();
            return view('configs/index', ['coentent' => $list['texts']]);
        }
    }
    public function about()
    {
        if($this->request->isPost()){
            $texts = input('post.');
            $result = Db::name('config')->where(['type'=>7])->update(['texts' =>$texts['texts'] ]);
            if (!$result) {
                return ajax_return_error('失败');
            }
            return ajax_return_adv('成功');
        }else{
            $list = Db::name('config')->where(['type'=>7])->find();
            return view('configs/about', ['coentent' => $list['texts']]);
        }
    }
}